$(function () {
    var starttiem = vm.getNowDate(" 00:00:00");
    var endtime = vm.getNowDate(" 23:59:59");
    Ajax.request({
        url: "../otcchangelog/queyrDataStatistics?starttime="+starttiem+"&endtime="+endtime,
        async: true,
        successCallback: function (r) {
            vm.dataStatistics = r.model;
        }
    });
    Ajax.request({
        url: "../otcchangelog/queryFinanceMes",
        async: true,
        successCallback: function (r) {
            vm.queryFinanceMes = r.model;
        }
    });

    $("#jqGrid").Grid({
        url: '../sportsuser/queryTopDspcUser',
        colModel: [
            {label: '昵称', name: 'nickname', index: 'nickname', width: 80,align:'center'},
            {label: '手机号码', name: 'phone', index: 'phone', width: 80,align:'center'},
            {label: 'DSPC总数', name: 'totalDspc', index: 'totalDspc', width: 80,align:'center'},
            {label: '上级昵称', name: 'tousername', index: 'tousername', width: 80,align:'center'},
            {label: '上级手机号码', name: 'touserphone', index: 'touserphone', width: 80,align:'center'}
         ]
    });
});

let vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        dataStatistics:{},
        queryFinanceMes:{},
        q:{
            datetime:'',
            count:''
        }
    },
    methods: {
        queryStatistics:function () {
            var starttiem = vm.changeDate(vm.q.datetime[0]);
            var endtime = vm.changeDate(vm.q.datetime[1]);
            Ajax.request({
                url: "../otcchangelog/queyrDataStatistics?starttime="+starttiem+"&endtime="+endtime,
                async: true,
                successCallback: function (r) {
                    vm.dataStatistics = r.model;
                }
            });
        },
        query:function () {
            vm.reload();
        },
        reloadSearch:function () {
            
        },changeDate:function (str) {
            var dateee = new Date(str).toJSON();
            var date = new Date(+new Date(dateee)+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'');
            return date;
        },getNow:function(s){
            return s < 10 ? '0' + s: s;
        },
        getNowDate:function (str) {
            var myDate = new Date();//获取当前年
            var year=myDate.getFullYear();//获取当前月
            var month=myDate.getMonth()+1;//获取当前日
            var date=myDate.getDate();
            var h=myDate.getHours();       //获取当前小时数(0-23)
            var m=myDate.getMinutes();     //获取当前分钟数(0-59)
            var s=myDate.getSeconds();
            var now=year+'-'+vm.getNow(month)+"-"+vm.getNow(date+str);
            return now;
        },
        reload: function (event) {
            vm.showList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'count': vm.q.count},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        }
    }
    
});